//
//  oldOrderInfo.m
//  laonianbang
//
//  Created by 勇拓 李 on 17/11/2.
//  Copyright © 2017年 zaiyou. All rights reserved.
//

#import "oldOrderInfo.h"

@implementation oldOrderInfo

- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    self = [super initWithDictionary:dictionary];
    
    if (dictionary[@"clientInfo"]) {
        self.clientInfo = [[oldClientInfo alloc] initWithDictionary:dictionary[@"clientInfo"]];
    }
    
    if (dictionary[@"serverInfo"]) {
        self.serverInfo = [[oldServerInfo alloc] initWithDictionary:dictionary[@"serverInfo"]];
    }
    
    if (dictionary[@"attendeeInfo"]) {
        self.attendeeInfo = [[oldAttendeeInfo alloc] initWithDictionary:dictionary[@"attendeeInfo"]];
    }
    
    if (dictionary[@"serveCategory"]) {
        self.serveCategory = [[oldServeCategory alloc] initWithDictionary:dictionary[@"serveCategory"]];
    }
    
    return self;
}

- (NSString *)getCurrentOrderStatus
{
    NSString *result = @"";
    
    switch ([self.status integerValue]) {
        case New_Order:
            result = @"等待接单";
            break;
        case Already_Accept:
            result = @"工作人员已接单";
            break;
        case Old_Cancel:
            result = [NSString stringWithFormat:@"已取消 取消原因:%@", self.cancelReason];
            break;
        case Supporter_Cancel:
            result = @"工作人员已取消";
            break;
        case Order_Begin:
            result = @"订单进行中";
            break;
        case Order_End:
            result = @"订单待支付";
            break;
        case Order_Payed:
            result = @"订单已支付";
            break;
        case Attendee_Cancel:
            result = @"家属已取消";
            break;
        default:
            break;
    }
    
    return result;
}

- (BOOL)ifCanceled
{
    if ([self.status integerValue] == Old_Cancel || [self.status integerValue] == Supporter_Cancel || [self.status integerValue] == Attendee_Cancel) {
        return YES;
    }
    
    return NO;
}

- (NSString *)oldStatusString
{
    NSString *result = @"已接单";
    
    switch ([self.status integerValue]) {
        case Already_Accept:
            result = @"已接单";
            break;
        case Order_End:
            result = @"待支付";
            break;
        default:
            break;
    }
    
    return result;
}

- (NSInteger)getTimeCostByMinutes
{
    return [self.serveCategory.timeCost integerValue]/60;
}

//New_Order = 0,
//Already_Accept,
//Old_Cancel,
//Supporter_Cancel,
//Order_Begin,
//Order_End,
//Order_Payed,
//Attendee_Cancel,

@end

@implementation oldClientInfo

@end

@implementation oldServerInfo

- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    self = [super initWithDictionary:dictionary];
    
    if (dictionary[@"addition"]) {
        self.addition = [[oldServerInfoAddition alloc] initWithDictionary:dictionary[@"addition"]];
    }
    
    return self;
}

@end

@implementation oldAttendeeInfo

- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
    self = [super initWithDictionary:dictionary];
    
    if (dictionary[@"addition"]) {
        self.addition = [[oldAttendeeInfoAddition alloc] initWithDictionary:dictionary[@"addition"]];
    }
    
    return self;
}

@end

@implementation oldServeCategory
@end

@implementation oldAttendeeInfoAddition
@end

@implementation oldServerInfoAddition
@end
